home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-11 | 3.7 KB | 183 lines | [TEXT/R*ch] |
- /*
-
- Listing 3: DecafObject .java
-
- DecafObject.java
- Define and create a new instance of our generic object.
-
- */
-
- // Import the generic Java classes.
- import java.applet.*;
- import java.awt.*;
- import java.io.*;
- import java.lang.*;
-
- // Our class definition.
- public class DecafObject extends Canvas
- {
- Color theBackgroundColor = Color.white;
- Color theTextColor = Color.white;
- Color menuColor[] = { Color.black, Color.green,
- Color.pink, Color.blue,
- Color.lightGray, Color.red,
- Color.cyan, Color.magenta,
- Color.white, Color.darkGray,
- Color.orange, Color.yellow,
- Color.gray };
- DecafObject theNextDecafObject;
- DecafObject thePreviousDecafObject;
- Rectangle boundsRect = new Rectangle();
- String theText = new String();
- boolean isSelected = false, insideGrow = false;
- static int panelDefaultX = 10, panelDefaultY = 10;
- static int panelDefaultWidth = 40;
- static int panelDefaultHeight = 20;
- static int buttonDefaultX = 10, buttonDefaultY = 10; static int buttonDefaultWidth = 40;
- static int buttonDefaultHeight = 20;
- static int textAreaDefaultX = 10;
- static int textAreaDefaultY = 10;
- static int textAreaDefaultWidth = 40;
- static int textAreaDefaultHeight = 20;
- int theID = 0;
-
- // theObjectType: 0 = Panel, 1 = Button, 2 = Text Area
- int theObjectType = 0;
-
- // theTextAlignment: 0 = Left, 1 = Center, 2 = Right
- int theTextAlignment = 0;
-
-
- public DecafObject()
- {
- }
-
- public void DoSetupCanvasComponent()
- {
- if ( theObjectType == 0 )
- boundsRect.reshape( panelDefaultX, panelDefaultY,
- panelDefaultWidth, panelDefaultHeight );
- else if ( theObjectType == 1 )
- boundsRect.reshape( buttonDefaultX, buttonDefaultY,
- buttonDefaultWidth, buttonDefaultHeight );
- }
-
- public void DoSetID( int newID )
- {
- this.theID = newID;
- }
-
- public int DoGetID()
- {
- return( this.theID );
- }
-
- public void DoSetBounds( Rectangle newBounds )
- {
- this.boundsRect = newBounds;
- }
-
- public Rectangle DoGetBounds()
- {
- return( this.boundsRect );
- }
-
- public void DoSetInsideGrow( boolean theSetting )
- {
- this.insideGrow = theSetting;
- }
-
- public boolean DoGetInsideGrow()
- {
- return( this.insideGrow );
- }
-
- public void DoSetSelected( boolean theSetting )
- {
- this.isSelected = theSetting;
- }
-
- public boolean DoGetSelected()
- {
- return( this.isSelected );
- }
-
- public void DoSetText( String theString )
- {
- theText = theString;
- }
-
- public String DoGetText()
- {
- return( this.theText );
- }
-
- public void DoSetObjectType( int objType )
- {
- theObjectType = objType;
- }
-
- public int DoGetObjectType()
- {
- return( this.theObjectType );
- }
-
- public void DoSetTextAlignment( int textAlign )
- {
- theTextAlignment = textAlign;
- }
-
- public void doSetBackColor( int theColor )
- {
- theBackgroundColor = menuColor[ theColor ];
- }
-
- public Color doGetBackColor()
- {
- return( this.theBackgroundColor );
- }
-
- public void doSetTextColor( int theColor )
- {
- theTextColor = menuColor[ theColor ];
- }
-
- public Color doGetTextColor()
- {
- return( this.theTextColor );
- }
-
- public void doSetNextDecafObject( DecafObject theDecafObject )
- {
- theNextDecafObject = theDecafObject;
- }
-
- public void doSetPreviousDecafObject( DecafObject
- theDecafObject )
- {
- thePreviousDecafObject = theDecafObject;
- }
-
- public DecafObject doGetNextDecafObject()
- {
- return theNextDecafObject;
- }
-
- public DecafObject doGetPreviousDecafObject()
- {
- return thePreviousDecafObject;
- }
-
- public void DoDeleteDecafObject()
- {
- if ( theNextDecafObject != null )
- theNextDecafObject.doSetPreviousDecafObject(
- thePreviousDecafObject );
-
- if ( thePreviousDecafObject != null )
- thePreviousDecafObject.doSetNextDecafObject(
- theNextDecafObject );
- }
-
- }
-